package com.qf.flash.mvp.presenter;

import com.qf.flash.http.HttpManager;
import com.qf.flash.model.MethodDetailsBean;
import com.qf.flash.mvp.contract.MethodDetailsContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

public class MethodDetailsPresenter extends BasePresenter<MethodDetailsContract.View> implements MethodDetailsContract.Presenter {
    @Override
    public void getMethodDetails(String id) {
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_METHOD_DETAILS(id)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<MethodDetailsBean>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<MethodDetailsBean> response) {
                        mRootView.setDetails(response.getData());
                    }
                })
        );
    }
}
